<?php
/**
 * Rooms Template for Room Booking component
 */
defined('_JEXEC') or die('Restricted access'); 
$document = & JFactory::getDocument();
$document->addScript(JURI::base() . 'components/com_roombooking/assets/js/jquery/jquery-1.5.2.min.js');
?>
<script type="text/javascript">
   jQuery.noConflict();
</script>
<form id="adminForm" action="index.php" method="post" name="adminForm">
<div id="editcell">
    <table class="adminlist">
    <thead>
        <tr>
            <td nowrap="nowrap" colspan="20">
                <select id="filter" name="filter_type" style="float: right;">
                    <?php
                        $filter_type = JRequest::getVar('filter_type');
                        if($filter_type == null)$filter_type = '0';
                    ?>
                    <option <?php if($filter_type == '0') echo 'selected="selected"'; ?> value="0">すべて</option>
                    <option <?php if($filter_type == '会議室') echo 'selected="selected"'; ?> value="会議室">会議室</option>
                    <option <?php if($filter_type == '会議ブース') echo 'selected="selected"'; ?> value="会議ブース ">会議ブース</option>
                </select>
                <label style="float: right">ルームタイプ：</label>
            </td>
        </tr>
        <tr>
        	<th width="5">
                <?php echo JText::_( '#' ); ?>
            </th>
        	<th width="20">
              <input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
            </th>
            <th>
                <?php echo JText::_( 'NAME' ); ?>
            </th>
            <th>
                <?php echo JText::_( 'ROOMTYPE' ); ?>
            </th>
            <th>
                <?php echo JText::_( 'BUILDING' ); ?>
            </th>
            <th>
                <?php echo JText::_( 'FLOOR' ); ?>
            </th>
            <th width="15">
                <?php echo JText::_( 'OPEN' ); ?>
            </th>
            <th width="5">
                <?php echo JText::_( 'ID' ); ?>
            </th>
        </tr>            
    </thead>
    <?php
    $k = 0;
     for ($i=0, $n=count( $this->items ); $i < $n; $i++)
    {
        $row =& $this->items[$i];
        $checked    = JHTML::_( 'grid.id', $i, $row->id );
        $link = 'index.php?option=com_roombooking&controller=room&task=edit&cid='. $row->id ;
        ?>
        <tr class="<?php echo "row$k"; ?>">
            <td>
                <?php echo $i+1; ?>
            </td>
            <td>
              <?php echo $checked; ?>
            </td>
             <td>
                <a href="<?php echo $link; ?>"><?php echo $row->name; ?></a>
            </td>
            <td>
                 <a href="<?php echo 'index.php?option=com_roombooking&controller=type&task=edit&cid='.$row->room_type_id; ?>">
                    <?php echo $row->room_type; ?>
                 </a>
            </td>
            <td>
                <a href="<?php echo 'index.php?option=com_roombooking&controller=building&task=edit&cid='.$row->id_building; ?>">
                <?php echo $row->building_name; ?></a>
            </td>
            <td>
                <?php echo $row->floor; ?>
            </td>
             
             <td>
                <?php  if($row->open==1) echo JText::_( 'Yes' ); else echo JText::_( 'No' ); ?>
            </td>
             <td>
                <?php echo $row->id; ?>
            </td>
        </tr>
        <?php
        $k = 1 - $k;
    }
    ?>
    </table>
</div>
 
<input type="hidden" name="option" value="com_roombooking" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input id="controller" type="hidden" name="controller" value="room" />
<input type="hidden" name="view" value="rooms" />
 
</form>
<script type="text/javascript">
    jQuery('#filter').change(function(){
//        alert('minhbkpro');
//        jQuery('#controller').val('');
        jQuery('#adminForm').submit();
    });
</script>